package com.wheesper.www.WheesperServer.Net.Session;
import com.wheesper.www.WheesperServer.Net.Chat.*;
import io.netty.channel.Channel;
import io.netty.buffer.Unpooled;

public abstract class Session {
	protected Integer _sessionId;
	protected Channel _channel;
	public Session(Integer _sessionId,Channel _channel) {
		this._sessionId = _sessionId;
		this._channel = _channel;
	}
	
	public  void writeToRemote(byte[] msg) {
		int msgLength = msg.length;
		_channel.write(Unpooled.copyInt(msgLength));
		_channel.writeAndFlush(Unpooled.copiedBuffer(msg));
		System.out.println(msg.length);
	}
	public abstract void send(String msg);
	public abstract void join(ChatRoom chatRoom);
	public abstract void left(ChatRoom chatRoom);
	public Integer getID() {
		return _sessionId;
	}
	public Channel getChannel() {
		return _channel;
	}
}
